package com.java.multipledatasource.thread.reentrantlock;

/**
 * @author hu
 * @version 1.0
 * @date 2021/1/16 0016 下午 12:27
 * @description
 */
public class Test01 {

    synchronized void m1() {
        for (int i = 0; i < 10; i++) {
            System.out.println(i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    synchronized void m2() {
        System.out.println("m2");
    }

    public static void main(String[] args) {
        Test01 test01 = new Test01();
        new Thread(test01::m1, "t1").start();

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        new Thread(test01::m2, "t2").start();
    }
}
